import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router'
import router from './router/index'
import './assets/fonts/iconfont.css'
import 'animate.css'
import {
	Form,
	Input,
	FormItem,
	Button,
	Row,
	Message,
	Container,
	Header,
	Aside,
	Main,
	Submenu,
	MenuItemGroup,
	MenuItem,
	Menu,
	Breadcrumb,
	BreadcrumbItem,
	Card,
	Table,
	TableColumn,
	Switch,
	Tooltip,
	Pagination,
	Dialog,
	MessageBox,
	Tag,
	Col,
	Tree,
	Select,
	Option,
	Cascader,
	Alert,
	Tabs,
	TabPane,
	Steps,
	Step,
	CheckboxGroup,
	CheckboxButton,
	Checkbox,
	Upload
} from 'element-ui'
import axios from 'axios'
import store from './store/index'
import ZkTable from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor'

// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor, /* { default global options } */)
Vue.use(Upload)
Vue.use(Checkbox)
Vue.use(CheckboxGroup)
Vue.use(CheckboxButton)
Vue.use(Steps)
Vue.use(Step)
Vue.use(ZkTable)
Vue.use(TabPane)
Vue.use(Tabs)
Vue.use(Cascader)
Vue.use(Alert)
Vue.component(Select.name, Select)
Vue.component(Option.name, Option)
Vue.component(Tree.name, Tree)
Vue.component(Col.name, Col)
Vue.component(Tag.name, Tag)
Vue.component(Dialog.name, Dialog)
Vue.component(Pagination.name, Pagination)
Vue.component(Tooltip.name, Tooltip)
Vue.component(Switch.name, Switch)
Vue.component(Table.name, Table)
Vue.component(TableColumn.name, TableColumn)
Vue.component(Card.name, Card)
Vue.component(Submenu.name, Submenu)
Vue.component(Breadcrumb.name, Breadcrumb)
Vue.component(BreadcrumbItem.name, BreadcrumbItem)
Vue.component(MenuItemGroup.name, MenuItemGroup)
Vue.component(MenuItem.name, MenuItem)
Vue.component(Menu.name, Menu)
Vue.component(Container.name, Container)
Vue.component(Header.name, Header)
Vue.component(Aside.name, Aside)
Vue.component(Main.name, Main)
Vue.component(Form.name, Form)
Vue.component(Input.name, Input)
Vue.component(FormItem.name, FormItem)
Vue.component(Button.name, Button)
Vue.component(Row.name, Row)
Vue.use(VueRouter)
Vue.config.productionTip = false
axios.defaults.baseURL = 'http://124.220.0.226:8889/api/private/v1'

axios.interceptors.request.use(
	function (config) {
		config.headers.Authorization = sessionStorage.getItem('token')
		return config
	},
	function (error) {
		return Promise.reject(error)
	}
)

Vue.filter('dataFormat',function(v){
	let data = new Date(v)
	let y = data.getFullYear()
	let m = (data.getMonth() + 1 + '').padStart(2,'0')
	let d = (data.getDate() + '').padStart(2,'0')
	let hh = (data.getHours() + '').padStart(2,'0')
	let mm = (data.getMinutes() + '').padStart(2,'0')
	let ss = (data.getSeconds() + '').padStart(2,'0')
	return `${y}-${m}-${d}  ${hh}:${mm}:${ss}`
})
new Vue({
	render: h => h(App),
	router,
	store,
	beforeCreate() {
		Vue.prototype.$bus = this
		Vue.prototype.$http = axios
		Vue.prototype.$message = Message
		Vue.prototype.$confirm = MessageBox.confirm
	},
}).$mount('#app')
